d. Multiple Fragment
  mainActivity
package srm.it.fragmentdemo
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        var state=0
        button.setOnClickListener {
            if(state==0)   {
supportFragmentManager.beginTransaction().replace(R.id.fragmentContainerView,first()).commit()
                state=1
            }
            else{  supportFragmentManager.beginTransaction().replace(R.id.fragmentContainerView,second()).commit()
                state=0
            } } } }
first Fragment
package srm.it.fragmentdemo
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import kotlinx.android.synthetic.main.fragment_first.*
import kotlinx.android.synthetic.main.fragment_first.view.*

class first : Fragment() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    }
    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        var root=inflater.inflate(R.layout.fragment_first, container, false)
        root.button2.setOnClickListener {
            Toast.makeText(context,"Fragment One",Toast.LENGTH_LONG).show()
        }
        return root
    } }

second Fragment
package srm.it.fragmentdemo
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import kotlinx.android.synthetic.main.fragment_second.*
import kotlinx.android.synthetic.main.fragment_second.view.*

class second : Fragment() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
}
    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        var root=inflater.inflate(R.layout.fragment_second, container, false)
        root.button3.setOnClickListener {
            Toast.makeText(context,"Fragment Second",Toast.LENGTH_LONG).show()
        }
        return root
    } }
